<template>
  <div class="common_wrap">
    <el-table :data="list" style="width: 100%; margin-bottom: 20px">
      <el-table-column
        prop="title"
        label="模块标题"
        align="center"
      ></el-table-column>
      <el-table-column prop="businessType" label="业务类型" align="center">
        <template slot-scope="scope">
          <div>{{ typeObj[scope.row.businessType] }}</div>
        </template>
      </el-table-column>
      <el-table-column
        prop="method"
        label="方法名称"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="operName"
        label="操作人员"
        align="center"
      ></el-table-column>
      <el-table-column prop="status" label="业操状态" align="center">
        <template slot-scope="scope">
          <div>{{ statusObj[scope.row.status] }}</div>
        </template>
      </el-table-column>

      <el-table-column prop="operTime" label="操作时间" align="center">
        <template slot-scope="scope">
          {{ onTimeFormat(scope.row.operTime) }}
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      style="text-align: right"
      @size-change="handleSizeChange"
      @current-change="currentChange"
      :current-page="queryForm.page"
      :page-size="queryForm.limit"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    ></el-pagination>
  </div>
</template>

<script>
import { getOperationLog } from "@/api/api";
import { timeFormat } from "@/utils/date";
export default {
  data() {
    return {
      queryForm: {
        page: 1,
        size: 10,
      },
      total: 0,
      list: [],
      typeObj: {
        0: "其它",
        1: "新增",
        2: "修改",
        3: "删除",
      },
      statusObj: {
        0: "正常",
        1: "异常",
      },
    };
  },
  created() {
    this.getPage();
  },
  methods: {
    getPage() {
      getOperationLog(this.queryForm).then((res) => {
        this.list = res.data.data.records;
        this.total = res.data.data.total;
      });
    },
    handleSizeChange(e) {
      this.queryForm.size = e;
      this.queryForm.page = 1;
      this.getPage();
    },
    currentChange(e) {
      this.queryForm.page = e;
      this.getPage();
    },
    onTimeFormat(e) {
      return timeFormat(e, "yyyy-MM-dd hh:mm:ss");
    },
  },
};
</script>

<style scoped lang="scss"></style>
